package com.yanqu.road.dataHelper.action.excel;

import com.yanqu.road.dataHelper.gameServer.GameServer;
import com.yanqu.road.dataHelper.manager.DataMgr;
import com.yanqu.road.dataHelper.repair.BaseRepair;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author xx
 * @Date 2020/11/11
 */
public class Skin extends BaseRepair {

    public Skin(GameServer gameServer) {
        super(gameServer);
    }

    @Override
    public void repair(long param1, String param2) {

    }

    //触发礼包一条龙三个日志
    public void go1(){
        List<Map<String, String>> listMap = new ArrayList<>();
        listMap = getLog1("2020-11-10","2020-11-13");
        DataMgr.addData(listMap);
    }

    private List<Map<String, String>> getLog1(String dateStart,String dateEnd) {
        List<Map<String, String>> dataList = new ArrayList<>();
        ResultSet rs = null;
        CallableStatement call = null;
        String sql = "SELECT * FROM t_l_goods WHERE goodsId = 109508 AND isGet = 1";
        // and shopType in(109,)
        try {
            call = getGameServer().getLogConnection().prepareCall(sql);
            int i=1;
            rs = call.executeQuery();
            while (rs.next()) {
                Map<String,String> temp = new ConcurrentHashMap<>();
                temp.put("serverId",String.valueOf(getGameServer().getServerInfo().getServerId()));
                temp.put("userId",checkNullToEmpty(rs.getString("userId")));
                temp.put("物品id",checkNullToEmpty(rs.getString("goodsId")));
                temp.put("获得值",checkNullToEmpty(rs.getString("num")));
                temp.put("当前值",checkNullToEmpty(rs.getString("nowNum")));
                temp.put("way",checkNullToEmpty(rs.getString("way")));
                temp.put("time",checkNullToEmpty(rs.getString("time")));
                dataList.add(temp);
            }
        } catch (SQLException ex) {
            getGameServer().getLogger().error("异常错误", ex);
        } finally {
            getGameServer().closeConnection(call, rs);
        }
        return dataList;
    }

}
